package com.yongchun.commons.exceptions;


import com.yongchun.commons.enums.BusinessExceptionEnum;

public class BusinessException extends Exception {

    public static String SPLIT_MESSAGE = "@@";
    public static String DEFALUT_CODE = "0000";


    private String msgError;
    private String codeError;


    /**
     *
     */
    private static final long serialVersionUID = 1L;

    public BusinessException(String message) {
        super(message);
        this.msgError = message;
        this.codeError = DEFALUT_CODE;
    }

    public BusinessException(int errorCode) {

        this(BusinessExceptionEnum.getBusiness(errorCode));

    }

    public BusinessException(ExceptionEnum business) {

        super(((business != null) ? business.getMessage() : "") + SPLIT_MESSAGE + ((business != null) ? business.getCode() : DEFALUT_CODE));
        this.msgError = (business != null) ? business.getMessage() : "";
        this.codeError = (business != null) ? business.getCode() + "" : DEFALUT_CODE;


    }


    public String getMsgError() {
        return msgError;
    }

    public void setMsgError(String msgError) {
        this.msgError = msgError;
    }

    public String getCodeError() {
        return codeError;
    }

    public void setCodeError(String codeError) {
        this.codeError = codeError;
    }

}
